# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo.exceptions import ValidationError


class StockPicking(models.Model):
    _inherit = 'stock.picking'

    def action_get_sale_order(self):
        self.ensure_one()
        if not self.sale_id:
            return
        domain = [('id', '=',  self.sale_id.id)]
        action = self.env.ref('sale.action_quotations_with_onboarding').read()[0]
        action['domain'] = domain
        return action

    def action_get_purchase_order(self):
        self.ensure_one()
        if not self.purchase_id:
            return
        domain = [('id', '=',  self.purchase_id.id)]
        action = self.env.ref('purchase.purchase_form_action').read()[0]
        action['domain'] = domain
        return action
